#include "InvitationHandler.h"
#include "MessageHelper.h"
#include "../room/RoomHandler.h"

extern MsgQueue queue_send;

void InvitationHandler::sendInvitation(const quint16& roomId, const quint16& userId) {
    MSG msg;
    msg.type = MSG::INVITE;

    msg.data.append(QByteArray::number(roomId));
    msg.data.append(',');
    msg.data.append(QByteArray::number(userId));

    qDebug() << "send";

    queue_send.append(msg);
}

void InvitationHandler::acceptInvitation(const quint16& id, const quint16& roomId) {
    roomHandler->joinRoom(roomId);
    delInvitation(id);
}

void InvitationHandler::declineInvitation(const quint16& id) {
    delInvitation(id);
}

void InvitationHandler::delInvitation(const quint16& id) {
    MSG msg;
    msg.type = MSG::DEL_INV;
    msg.data.append(QByteArray::number(id));

    queue_send.append(msg);
}